package com.geostar.constructionland.analyse.controller;

import com.geostar.constructionland.common.entity.analyse.AlyTypeMapping;
import com.geostar.constructionland.analyse.service.mapping.IAlyTypeMappingService;
import com.geostar.constructionland.common.entity.response.ServerResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;

/**
 * @author yelll
 * @since 2020-6-9 16:40
 **/
@RestController
@Api(value = "分析映射关系接口")
@RequestMapping("/alyTypeMpi")
public class AlyTypeMpiController {
    @Autowired
    IAlyTypeMappingService alyTypeMappingService;
    @RequestMapping("/add")
    @ApiOperation("新增分析映射关系")
    @ResponseBody
    public ServerResponse addAlyTypeMpi(@Valid AlyTypeMapping alyTypeMapping){
        alyTypeMappingService.save(alyTypeMapping);
        return ServerResponse.createBySuccessMessage("保存映射关系成功!");
    }

    @RequestMapping("/del")
    @ApiOperation("删除分析映射关系")
    @ResponseBody
    public ServerResponse delAlyTypeMpi(@NotBlank(message = "映射ID不能为空") @RequestParam(value = "mappingId") String mappingId){
        alyTypeMappingService.removeById(mappingId);
        return ServerResponse.createBySuccessMessage("删除成功!");
    }

    @RequestMapping("query")
    @ResponseBody
    @ApiOperation("查询分析映射关系")
    public ServerResponse getAlyMp(){
        return null;
    }


}
